
const { plugin } = require("../../../../common/utils")
const { createTask } = require("../../aaa")
exports.createBlackScreenDetectTask = function(config, callback) {
    return createTask(
        Object.assign({}, config || {}, {interval: 200}), 
        (args, context) => {
            if (!context["detect-black-screen"]) {
                return {}
            }
            let capture = images.captureScreen()
            if (capture == undefined) {
                return 
            }
            let bitmap = capture.getBitmap()
            let result = plugin.blackScreenDetect(bitmap)
            let objects = {}
            if (result) {
                objects["black-screen"] = [
                    {
                        "h": 100,
                        "label": "black-screen",
                        "prob": 1,
                        "w": 100,
                        "x": 100,
                        "y": 100
                    }
                ]
                context["detect-black-screen"] = false
            } else {
                objects["black-screen"] = []
            }
            return objects
        }, 
        callback
    ) 
} 